import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: "/ai",
    name: "ai",
    component: () => import("@/views/ai/index.vue")
  },
  {
    path: "/",
    redirect: "/login"//重定向到登录页
  },
  { //登录页面

    path: "/login",
    name: "login",
    component: () => import("@/views/login/index.vue")
  },
  { //layout页面
    path: "/layout",
    name: "layout",
    component: () => import("@/views/layout/index.vue"),
    // 其他模块几乎都是layout的二级路由
    children: [
      { //进入layout页默认进入主页的二级路由
        path: "/",
        name: "Home",
        component: () => import("@/views/home/index.vue"),
        meta: {
          title: []
        }
      },
      { //管理员页面
        path: "admin",
        name: "Admin",
        component: () => import("@/views/admin/index.vue"),
        meta: {
          title: ["用户管理", "管理员"]
        }
      },
      { //学员页面
        path: "student",
        name: "Student",
        component: () => import("@/views/student/index.vue"),
        meta: {
          title: ["用户管理", "学员管理"]
        }
      },
      { //学员页面
        path: "video",
        name: "Video",
        component: () => import("@/views/video/index.vue"),
        meta: {
          title: ["课程管理", "视频管理"]
        }
      },
      { //课程添加页面
        path: "courseadd",
        name: "courseadd",
        component: () => import("@/views/addCourse/index.vue"),
        meta: {
          title: ["课程管理", "课程添加"]
        }
      },
      { //课程列表模块
        path: "courselist",
        name: "courselist",
        component: () => import("@/views/courselist/index.vue"),
        meta: {
          title: ["课程管理", "课程列表"]
        }
      },
      { //课程列表模块
        path: "map",
        name: "map",
        component: () => import("@/views/map/index.vue"),
        meta: {
          title: ["课程管理", "地图"]
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
